#!/bin/bash

set -e

target_commit=$(
  git log -75 --oneline --decorate --graph --all --color=always | \
  fzf --ansi --no-sort --reverse --tiebreak=index | \
  sed -E 's/.* ([0-9a-f]{7}) .*/\1/' | \
  tr -d '\n'
)

printf "%s\n" "$target_commit" | xsel -pb

printf "Commit hash copied ($target_commit)\n"
